using UnityEngine;

[ExecuteInEditMode]
public class AimHit : MonoBehaviour
{
	public float time = 3f;

	public float cDps;

	public float cDamage;

	public ShowgameObjectsFromPercent[] objectsForEnable;

	private void Update()
	{
		if (objectsForEnable != null)
		{
			for (int i = 0; i < objectsForEnable.Length; i++)
			{
				if (cDamage > 0f)
				{
					objectsForEnable[i].SetPertcent(cDps / cDamage);
				}
				else
				{
					objectsForEnable[i].SetPertcent(0f);
				}
			}
		}
		if (GameController.instance != null && !GameController.instance.playerScript.isDead)
		{
			cDamage = Mathf.Clamp(cDamage - cDps / time * Time.deltaTime, 0f, 99999f);
		}
		else
		{
			cDamage = 0f;
		}
	}

	public void SetDamage(float damage, float dps)
	{
		cDamage += damage;
		cDps = dps;
	}
}
